﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace HuiLian.Data.DataAccess.Interface
{
    public interface IBaseDao<Entity> where Entity : class, new()
    {
        /// <summary>
        /// 增
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        Task<int> Insert(params Entity[] entities);

        /// <summary>
        /// 删
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        Task<int> Delete(params Entity[] entities);

        /// <summary>
        /// 改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> Update(params Entity[] entities);

        /// <summary>
        /// 查
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<Entity> Select(Expression<Func<Entity, bool>> where);

        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        IQueryable<Entity> GetList(Expression<Func<Entity, bool>> where);

        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        IQueryable<Entity> GetList();

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <typeparam name="Key"></typeparam>
        /// <param name="where"></param>
        /// <param name="orderby"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        IQueryable<Entity> PageQuery<Key>(
            Expression<Func<Entity, bool>> where, 
            Expression<Func<Entity, Key>> orderby, 
            int pageSize, int pageIndex, bool isAsc = true);
    }
}
